// ************************* 78 character ruler *****************************
// TSTM.h -- TSTM Test DLL common definitions
//
// $Author: Liu Rongwu $
// $Header: /rfbb.h 2     Liu Rongwu $
//
// (c) 2010 Nokia Siemens Networks.
// ************************* 78 character ruler *****************************

#ifndef TSTM_H_INCLUDED
#define TSTM_H_INCLUDED

#include "stdtst.h"
#include "tsutil.h"
#include "EELog.h"
#include <vpptype.h>
#include "CVIMacros.h"
#include <cvintwrk.h> 
#include "comdef.h"
#include "BitOrByte_ProcFunc.h"
#include <CalFileParser.h> // CalFileParser ActiveX controller 


/////////////////////////////////////////////////////////////////////////////
// Definitions
/////////////////////////////////////////////////////////////////////////////
#define TESTPLAN_BASE_PATH "RunState.ProcessModelClient.Data.FileGlobalDefaults.TESTPLAN.MainSequence"
#define TESTPLAN_BASE_PATH_EXT "RunState.ProcessModelClient.Data.FileGlobalDefaults.TESTPLAN"  //Defined by LRW  

#define TEST_NAME_EVENT_FMTSTR "##########  %s  ##########"
#define TEST_FAIL_DIAG_FMTSTR "# --- START FAILURE DIAGNOSTICS DATA ---#\n%s# --- END FAILURE DIAGNOSTICS DATA--- #"
#define LINEFEED 10 // NOT USED ANYWHERE?

#define TSTM_RESULT_PASS 0
#define TSTM_RESULT_FAIL 1
#define TSTM_RESULT_BOGUS 999.9

#define TSTM_FTP_MODE_ASCII  1
#define TSTM_FTP_MODE_BINARY 2
#define MAIN 0
#define DIV 1  
#define MAXGETBYTE 8

//#if(ON_OFF == SIMU_VERS)
//#define NO_PSU
//#endif
/////////////////////////////////////////////////////////////////////////////
// Macro definitions
/////////////////////////////////////////////////////////////////////////////

// General Error Catch for error or warnings...
// Expects that called function handles its error message to error log
#define ErrChk(fCall)\
\
if ((error = (fCall)) != 0) {\
   if(g_hEventLog != 0)\
      EELog_INEventLogShow(g_hEventLog,NULL);\
   if(error < 0) goto Error;\
} else

// Error Catch for HTDC errors or warnings...
// Expects that called function handles its error message to error log
#define htdcSetupErrChk(fCall, messageName)\
\
if ((error = (fCall)) != 0) {\
   error = -1;\
   sprintf(errMsg, "Error loading/sending message \"%s\"", messageName);\
   goto Error;\
} else


/////////////////////////////////////////////////////////////////////////////
// Globals
/////////////////////////////////////////////////////////////////////////////
extern CAObjHandle g_hEventLog;
extern CAObjHandle g_hErrorLog;
extern CAObjHandle g_hThreadPostUIMessage;
//wendy add on Sept. 21
extern CAObjHandle g_hCalFileParser;

extern unsigned short g_uiHwSwID;      // 02092008
extern char g_szSwVersion[256];        // 02092008
extern char g_szHwVersion[16];         // 02092008
extern char g_szProductCode[16];       // 02092008
extern char g_szSerialNumber[16];      // 02092008
extern int 	g_hCmonAgent; 
extern int g_hFrmonAgent;
extern int  g_hShellCommand;
extern char	g_szDUTIP[64];
extern int	g_iPort;
extern int  g_iShellCommandPort;

extern char g_szCommandToSend[256];
extern char g_szCmonErrorDescr[256]; 
extern char g_szCmonReadString[512];
extern int  g_iCmonErrorCode;


/////////////////////////////////////////////////////////////////////////////
// Function prototypes
/////////////////////////////////////////////////////////////////////////////

// XML UTILITIES:
int GetActiveBuildVersionFromFileDirectory( char* pszFileDirectory, char* pszBuildVersion );
int PostMessageToGui(char *pszMessage); 

// TO BE CHECKED WHERE THESE ARE DECLARED....

// Telnet Utilities
int CmonAgent_Action(char* pszCommand, int iTimeout);
int CmonAgent_PassFail(char* pszCommand, int iTimeout, int* PassFail);
int CmonAgent_Numeric(char* pszCommand, int iTimeout, char* pszPattern, double* dMeasurement);
int CmonAgent_String(char* pszCommand, int iTimeout, char* pszPattern, int* PassFail);
int CmonAgentWriteReadUntil( char* pszCommand,char* pszSearchString,char*  pszReturnString, long iTimeOut,int iPrintLog  );
int CmonAgentMultiString(char* pszCommand, int iTimeout, _FIND_PATTERN_GET_SRING* pszFindPattern, int iTotlePatternNum,int* PassFail);
//int CmonAgentMultiNumeric(char* pszCommand, int iTimeout, _FIND_PATTERN_AND_NUMERIC* pszFindPattern, int iTotlePatternNum,int* PassFail);
int CmonAgentMultiNumeric(char* pszCommand, int iTimeout, _FIND_PATTERN_AND_NUMERIC* pszFindPattern, int iTotlePatternNum);
int ShellCommand_HexNumeric(char* pszCommand, int iTimeout, char* pszPattern, double* dMeasurement);
int Shmon_IntegerNumeric(char* pszCommand, int iTimeout, char* pszPattern, long int* lMeasurement);

//shell command and return string handle
int ShellCommand_Numeric(char* pszCommand, int iTimeout, char* pszPattern, double* dMeasurement);
int ShellCommand_Action(char* pszCommand, int iTimeout);
int Shmon_SendAndAck(char* pszCommand, int iTimeout,const char* pszAck);
int Shmon_RunScript(char* pszCommand, int iTimeout);
int Shmon_RunCmdNoAck(char* pszCommand, int iTimeout);
int ShellCommand_PassFail(char* pszCommand, int iTimeout, int* PassFail) ;
int ShellCommand_Hex(char* pszCommand, int iTimeout, char* pszPattern, char* pszHex); 
int ShellCommand_String(char* pszCommand, int iTimeout, char* pszPattern, int* PassFail);
int Shmon_GetStringAccordingToPattern(char* pszCommand, int iTimeout,_SHMON_FIND_PATTERN_GET_SRING* pszFindPattern, int* PassFail);
int Shmon_GetNumericAccordingToPattern(char* pszCommand, int iTimeout,_SHMON_FIND_PATTERN_GET_NUMERIC* pszFindPattern, int* PassFail);
int ShellCommandWriteReadUntil(char* pszCommand,char* pszSearchString,char* pszReturnString, int iTimeOut,int iPrintLog ) ;
int FRmonAgent_String(char* pszCommand, int iTimeout, char* pszPattern, int* PassFail);
int FRmonAgentWriteReadUntil( char* pszCommand,char* pszSearchString,char*  pszReturnString, long iTimeOut,int iPrintLog  );
int Frmon_RunCmdNoAck(char* pszCommand, int iTimeout);
int FRmonAgent_Numeric(char* pszCommand, int iTimeout, char* pszPattern, double* dMeasurement);
int ShellCommand_StringSpecial(char* pszCommand, int iTimeout, char* pszPattern, int* PassFail);   
int ShellCmdWriteAndCompResult(const char *cShellCmd,char *cResult,int parm1);
int ShellCmdReadAndGetReturnString(const char *cShellCmd,char* cSearchString,char *cReturnString,int TimeoutMs);
int RfbbFTPDownloadFromRemote(const char *localFile,const char *remoteFile); 
int RfbbInetTelnetOpen (const char *telnetServer, unsigned short remotePort,unsigned short localPort);
int RfbbInetFTPAutoSend (const char *ftpServer, const char *userName,
                             const char *password, const char *localFile,
                             const char *remoteFile, int transferType);


#endif // TSTM_H

// ************************* 78 character ruler *****************************
//                            End of header file
// **************************************************************************
